package com.zx.notification.common.param;

import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Create;
import com.zx.validation.groups.Query;
import com.zx.validation.groups.StatusUpdate;
import com.zx.validation.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 * description: 通知模板参数 <br>
 * create: 2025-10-15
 * </p>
 *
 * @author zhou  xun
 */
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class NotificationTemplatesParam implements Serializable, Create, Update, StatusUpdate, Query {
    /**
     * 模板ID
     */
    @ParameterValidation(index = 0, desc = "模板ID", rules = {ValidateRulesEnum.NOT_NULL})
    private String id;

    /**
     * 模板编码
     */
    @ParameterValidation(index = 0, desc = "模板编码", rules = {ValidateRulesEnum.NOT_NULL})
    private String templateCode;

    /**
     * 模板名称
     */
    @ParameterValidation(index = 0, desc = "模板名称", rules = {ValidateRulesEnum.NOT_NULL})
    private String templateName;

    /**
     * 业务类型
     */
    @ParameterValidation(index = 0, desc = "业务类型", rules = {ValidateRulesEnum.NOT_NULL})
    private String bizType;

    /**
     * 模板内容
     */
    @ParameterValidation(index = 0, desc = "模板内容", rules = {ValidateRulesEnum.NOT_NULL})
    private String templateContent;

    /**
     * 支持渠道: INBOX,WEBSOCKET,SMS,EMAIL,APP_PUSH,WECHAT
     */
    @ParameterValidation(index = 0, desc = "支持渠道", rules = {ValidateRulesEnum.NOT_NULL})
    private String supportedChannels;

    /**
     * 消费模式: QUEUE-点对点(单用户消费),TOPIC-广播(多用户订阅)
     */
    @ParameterValidation(index = 0, desc = "消费模式", rules = {ValidateRulesEnum.NOT_NULL})
    private String consumeMode;

    /**
     * 状态: 0-停用 1-启用
     */
    @ParameterValidation(index = 0, desc = "状态", rules = {ValidateRulesEnum.NOT_NULL})
    private Integer status;

    /**
     * 创建者
     */
    private String createBy;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新者
     */
    private String updateBy;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 备注
     */
    private String remark;

    /**
     * 当前页码
     */
    @ParameterValidation(index = 0, desc = "当前页码", rules = {ValidateRulesEnum.NUMBER_MIN}, numberMin = 1)
    private Long pageNum;

    /**
     * 每页条数
     */
    @ParameterValidation(index = 0, desc = "每页条数", rules = {ValidateRulesEnum.NUMBER_MIN, ValidateRulesEnum.NUMBER_MAX}, numberMin = 1, numberMax = 1000)
    private Long pageSize;

    /**
     * 创建时间开始
     * 用于时间范围查询，查询大于等于该时间的记录
     */
    private LocalDateTime createTimeStart;

    /**
     * 创建时间结束
     * 用于时间范围查询，查询小于等于该时间的记录
     */
    private LocalDateTime createTimeEnd;

    @Override
    public Set<String> getCreateGroupFields() {
        return Set.of("templateCode", "templateName", "bizType", "templateContent", "supportedChannels", "consumeMode");
    }

    @Override
    public Set<String> getUpdateGroupFields() {
        return Set.of("id", "templateName", "templateContent", "supportedChannels", "consumeMode");
    }

    @Override
    public Set<String> getStatusUpdateGroupFields() {
        return Set.of("id", "status");
    }

    @Override
    public Set<String> getQueryGroupFields() {
        return Set.of("templateCode", "templateName", "bizType", "supportedChannels", "status", "pageNum", "pageSize",
                "createTimeStart", "createTimeEnd");
    }
}